<template>
	<view class="content">
		<u-divider text="测试storege/storageExpire" textSize="14"></u-divider>

		<u-button @click="getStorage">获取当前项目的 storage </u-button>
		<u-button @click="clearStorage">清空当前项目的 storage </u-button>

		<u-button @click="testJiami">测试加密效果 </u-button>
	
		<u-button @click="getInfo">测试get接口</u-button>
		<u-button @click="toLogin"> 跳转登录界面 </u-button>
		<u-button @click="toLoginOut"> 退出登录 </u-button>
		
		<u-button @click="setTabbar(false)"> 测动态设置 隐藏 tabbar </u-button>
		<u-button @click="setTabbar(true)"> 测试动态设置 出现 tabbar </u-button>
	</view>
</template>

<script>
	import {
		storage,
		storageExpire,
		storageData
	} from "@/common/util/storage/index.js"
	
	import { getInfo } from "@/api/api.js"
	import { encrypt, decrypt } from "@/common/util/secret.js"
	import { removeToken } from "@/common/util/auth"

	export default {
		data() {
			return {}
		},
		onLoad() {
			// 测试 storage
			// console.log('storageData', storageData())
			// storage.set('name', 1)
			// console.log(storage.get('name'))
			
			// 
		},
		
		onshow() {
			 
		},
		methods: {
			setTabbar(v) {
				uni.setTabBarItem({
				  index: 0,
				  text: '123123123',
				  visible: v
				})
			},
			toLoginOut() {
				console.log('执行登出操作')
				this.$store.dispatch('LogOut')
			},
			toLogin() {
				this.$tab.navigateTo('/pages/login/login')
			},
			
			clearStorage() {
				console.log('清空token')
				storage.clean()
			},
			
			getInfo() {
				getInfo().then(res => {
					console.log(res)
				})
			},
			// 获取当前app 的缓存
			getStorage() {
				console.log(storageData())
			},
			
			
			// 测试加密
			testJiami () {
				let  oldV = '123325asdasd'
				
				let jiamihou =  encrypt(oldV)
				
				let jiemihou = decrypt(jiamihou)
				
				console.log('测试加密', oldV, jiamihou, jiemihou)
			}

		}
	}
</script>

<style>
	.content {}
</style>